package com.zyz.sunliky.quartz;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.event.ContextRefreshedEvent;

/**
 * @Author yyy
 * @Description 启动定时任务
 */
@Configuration
@MapperScan({"com.zyz.sunliky.mapper", "com.zyz.sunliky.mapper.yunshu"})
public class SchedulerListener implements ApplicationListener<ContextRefreshedEvent> {

    @Autowired
    public TaskManager taskManager;

    /**
     * 监听事件
     * @param event
     */
    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        try {
            taskManager.executeTasks();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }


}
